﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace array_demo.Model.Linked
{
    /// <summary>
    /// 双向链表
    /// </summary>
    /// <typeparam name="E"></typeparam>
    public class DoubleLinkedList<E>
    {
        /// <summary>
        /// 定义节点对象
        /// </summary>
        private class Node
        {

            public Node pre;

            // 当前的元素
            public E e;

            // 当前指向下一个节点的引用
            public Node next;

            /// <summary>
            ///初始化构造函数
            /// </summary>
            /// <param name="e"></param>
            /// <param name="next"></param>
            public Node(Node pre, E e, Node next)
            {
                this.pre = pre;

                this.e = e;

                this.next = next;
            }

            /// <summary>
            /// 初始化构造函数 不指定下一级别
            /// </summary>
            /// <param name="e"></param>
            public Node(E e)
            {
                this.pre = null;
                this.e = e;
                this.next = null;
            }

            public override string ToString()
            {
                return e.ToString();
            }
        }

        /// <summary>
        /// 头结点
        /// </summary>
        private Node head;


        /// <summary>
        /// 链表中的元素个数
        /// </summary>
        private int N;

        public DoubleLinkedList()
        {
            head = null;
            N = 0;
        }
    }
}
